﻿using System;
using System.Collections.Generic;
using System.Text;
using EZCRS.HCMS.Bll.baseinfo;
using EZCRS.HCMS.Entity;
using EZCRS.HCMS.Bll;
using System.Collections;

namespace EZCRS.HCMS.myajax
{
    public class AjaxHotelInfo:MainBase
    {
        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string gatfacility()
        {
            //return "";
            StringBuilder sb = new StringBuilder();
            List<HCRS_Facility> _facility = new BllFacility().getf(0,"");
            List<HCRS_Facilityclass> _fclass = new BllFacility().getfclass();
           

            string cfacilites = new BllFacility().gethotelfacility(BasPropertyId);
            cfacilites = "、" + cfacilites;
            foreach (HCRS_Facilityclass _cls in _fclass)
            {
                int i = 0;
                sb.Append("<table  align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"  class=\"main-table\">");
                sb.Append("<tr>");
                sb.Append("<th  class=\"minfo-title\">"+_cls.classname+"</th>");
                sb.Append("</tr>");
                sb.Append("<tr>");
                sb.Append("<td>");
                sb.Append("<table  align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"  width=\"100%\">");
                foreach (HCRS_Facility _f in _facility)
                {
                    if (_f.fclass == _cls.Id)
                    {
                        if (i % 5 == 0)
                        {
                            sb.Append("<tr>");
                        }


                        i++;
                        sb.Append("<td><input type=\"checkbox\" name=\"ckl\" value=\"" + _f.fname + "\"");

                        if (cfacilites.IndexOf("、"+_f.fname) >= 0)
                            sb.Append(" checked ");
                        sb.Append(">" + _f.fname + "</td>");


                        if (i > 1 && i % 5 == 0)
                        {
                            sb.Append("</tr>");
                        }
                    }
                }
                sb.Append("</table>");
                sb.Append("</td>");
                sb.Append("</tr>");
                sb.Append("</table>");              
            }
            return sb.ToString();
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string gatfacilitybase(string ltype,string nkey)
        {
            //return "";
            StringBuilder sb = new StringBuilder();
            List<HCRS_Facility> _facility = new BllFacility().getf(Convert.ToInt32(ltype),nkey);
            List<HCRS_Facilityclass> _fclass = new BllFacility().getfclass();
            
            foreach (HCRS_Facilityclass _cls in _fclass)
            {
                int i = 0;
                sb.Append("<table  align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"  class=\"main-table\">");
                sb.Append("<tr>");
                sb.Append("<th  class=\"minfo-title\">" + _cls.classname + "</th>");
                sb.Append("</tr>");
                sb.Append("<tr>");
                sb.Append("<td>");
                sb.Append("<table  align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"  width=\"100%\">");
                foreach (HCRS_Facility _f in _facility)
                {
                    if (_f.fclass == _cls.Id)
                    {
                        if (i % 5 == 0)
                        {
                            sb.Append("<tr>");
                        }

                        i++;
                        sb.Append("<td><table><tr  onDblClick=\"javascript:modify(this,1,1);\"><td style=\"width:30px;\">" + _f.Id.ToString() + "</td><td width=\"80%\">" + _f.fname + "</td><td style=\"width:20px;\"><a href=\"javascript:del('" + _f.Id.ToString() + "');\"><img width=\"19px\" height=\"19px\" border=\"0\" alt=\"delete\" src=\"/Themes/Standard/Images/loading_close.gif\"></a></td></tr></table></td>");

                        
                        if (i > 1 && i % 5 == 0)
                        {
                            sb.Append("</tr>");
                        }
                    }
                }
                sb.Append("</table>");
                sb.Append("</td>");
                sb.Append("</tr>");
                sb.Append("</table>");
            }
            return sb.ToString();
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string delfacility(string sid)
        {
            int id = Convert.ToInt32(sid);
            if (new BllFacility().delfacility(id))
                return "1";
            else
                return "0";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string updatefacility(string sid, string sname)
        {
            HCRS_Facility _f = new HCRS_Facility();
            _f.Id = Convert.ToInt32(sid);
            _f.fname = sname;

            if (new BllFacility().insertorupdate(_f))
                return "1";
            else
                return "0";
        }

        #region 未实现
        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getfacilityall()
        {
            //return "";
            StringBuilder sb = new StringBuilder();
            List<HCRS_Facility> _facility = new BllFacility().getf(0,"");
            List<HCRS_Facilityclass> _fclass = new BllFacility().getfclass();
            string pid = DataAcl.CFun.GetCookies("cms", "p");
            string cfacilites = new BllFacility().gethotelfacility(Convert.ToInt32(pid));
            cfacilites = "、" + cfacilites;
            foreach (HCRS_Facilityclass _cls in _fclass)
            {
                int i = 0;
                sb.Append("<table  align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"  class=\"maininfo\">");
                sb.Append("<tr>");
                sb.Append("<td  class=\"minfo-title\">" + _cls.classname + "</td>");
                sb.Append("</tr>");
                sb.Append("<tr>");
                sb.Append("<td>");
                sb.Append("<table  align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"  width=\"100%\">");
                foreach (HCRS_Facility _f in _facility)
                {
                    if (_f.fclass == _cls.Id)
                    {
                        if (i % 5 == 0)
                        {
                            sb.Append("<tr>");
                        }


                        i++;
                        sb.Append("<td><input type=\"checkbox\" name=\"ckl\" value=\"" + _f.fname + "\"");

                        if (cfacilites.IndexOf("、" + _f.fname) >= 0)
                            sb.Append(" checked ");
                        sb.Append(">" + _f.fname + "</td>");


                        if (i > 1 && i % 5 == 0)
                        {
                            sb.Append("</tr>");
                        }
                    }
                }
                sb.Append("</table>");
                sb.Append("</td>");
                sb.Append("</tr>");
                sb.Append("</table>");
            }
            return sb.ToString();
        }

        


        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string modifyfacility(string id,string names)
        {
            return "";
        }
        #endregion

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string savefacility(string results)
        {
            results=results.Replace(",", "、");
            if (new BllFacility().savehotelfacility(BasPropertyId, results))
                return "1";
            else
                return "";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string savefacilityother()
        {
            string pid = BasPropertyId.ToString();
            ArrayList list = new BllFacility().gethotelother(Convert.ToInt32(pid));
            StringBuilder sb = new StringBuilder();
            sb.Append("<table  align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"  class=\"main-table\">");
            sb.Append("<tr>");
            sb.Append("<td  class=\"minfo-title\">"+EZCRS.HCMS.myajax.Site.StrMeetingFacility+"</td><td  class=\"minfo-title\">"+EZCRS.HCMS.myajax.Site.StrFoodFacility+"</td><td  class=\"minfo-title\">"+EZCRS.HCMS.myajax.Site.StrPartFacility+"</td>");
            sb.Append("</tr>");
            sb.Append("<td><textarea id=\"hy\" cols=\"40\" rows=\"6\">" + list[0].ToString() + "</textarea></td><td><textarea id=\"cy\" cols=\"40\" rows=\"6\">" + list[1].ToString() + "</textarea></td><td><textarea id=\"bc\" cols=\"40\" rows=\"6\">" + list[2].ToString() + "</textarea></td>");
            sb.Append("</tr>");
            sb.Append("<tr>");
            sb.Append("<td  class=\"minfo-title\">"+EZCRS.HCMS.myajax.Site.StrHealthFacility+"</td><td  class=\"minfo-title\">"+EZCRS.HCMS.myajax.Site.StrSafeFacility+"</td><td  class=\"minfo-title\">"+EZCRS.HCMS.myajax.Site.StrPrize+"</td>");
            sb.Append("</tr>");
            sb.Append("<td><textarea id=\"kl\" cols=\"40\" rows=\"6\">" + list[3].ToString() + "</textarea></td><td><textarea id=\"aq\" cols=\"40\" rows=\"6\">" + list[4].ToString() + "</textarea></td><td><textarea id=\"rh\" cols=\"40\" rows=\"6\">" + list[5].ToString() + "</textarea></td>");
            sb.Append("</tr>");
            sb.Append("</table>");
            return  sb.ToString();
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string saveother(string hy,string cy,string bc,string kl,string aq,string rh)
        {
            string[] results = new string[] {hy,cy,bc,kl,aq,rh };
            if (new BllFacility().savehotelother(BasPropertyId, results))
                return "1";
            else
                return "";
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string gettax()
        {
            int pid = BasPropertyId;
            List<HCRS_TaxRule> _list = new BllHCRS_Tax().getitem(" property_id=" + pid.ToString() + "  and languagetype=" + base.LanguageId.ToString() + " ");
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tcountry\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"95%\"><tr class=\"title1\" height=\"26\"><td style=\"color: white;width:60px;\">"+EZCRS.HCMS.myajax.Site.StrNumb+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrCode+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrName+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrRemark+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrUpdateTime+"</td><td style=\"color: white;width:60px\">"+EZCRS.HCMS.myajax.Site.StrDetail+"</td></tr>");
            int row = 0;
            foreach (HCRS_TaxRule _tax in _list)
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\"");
                rstr.Append(" >");
                rstr.Append("<td>" + row.ToString() + "</td>");
                rstr.Append("<td>" + _tax.TypeCode + "</td>");
                rstr.Append("<td >" + _tax.TypeCode + "</td>");
                rstr.Append("<td>"+_tax.Description+"</td>");
                rstr.Append("<td>"+_tax.updatetime.ToString()+"</td>");
                rstr.Append("<td><a href=\"taxadd.aspx?id=" + _tax.id.ToString() + "\"><img src=\"../../image/modify.gif\"  border=\"0\"/></a></td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            return rstr.ToString(); 
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getguarule()
        {
            int pid = BasPropertyId;
            List<HCRS_GuaRule> _list = new BllH_guarule().getitem(" property_id=" + pid.ToString() + " and languagetype=" + base.LanguageId.ToString() + "  ");
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tcountry\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"95%\"><tr class=\"title1\" height=\"26\"><td style=\"color: white;width:60px\">" + EZCRS.HCMS.myajax.Site.StrNumb + "</td><td style=\"color: white;\">" + EZCRS.HCMS.myajax.Site.StrGuaranteCode + "</td><td style=\"color: white;\">" + EZCRS.HCMS.myajax.Site.StrName + "</td><td style=\"color: white;\">" + EZCRS.HCMS.myajax.Site.StrRemark + "</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrClass+"</td><td style=\"color: white;\">" + EZCRS.HCMS.myajax.Site.StrUpdateTime + "</td><td style=\"color: white;width:60px\">"+EZCRS.HCMS.myajax.Site.StrDetail+"</td></tr>");
            int row = 0;
            foreach (HCRS_GuaRule _gua in _list)
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" ");
                rstr.Append(" >");
                rstr.Append("<td>" + row.ToString() + "</td>");
                rstr.Append("<td>" + _gua.Grule + "</td>");
                rstr.Append("<td>" + _gua.Grulename + "</td>");
                rstr.Append("<td>" + _gua.GDescription + "</td>");
                rstr.Append("<td>" + _gua.Grulelevel.ToString() + "</td>");
                rstr.Append("<td>" + _gua.updatetime.ToString() + "</td>");
                rstr.Append("<td><a href=\"guaruleadd.aspx?id=" + _gua.id.ToString() + "\"><img src=\"../../image/modify.gif\"  border=\"0\"/></a></td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            return rstr.ToString(); 
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getcxlrule()
        {
            int pid = BasPropertyId;
            List<HCRS_CxlRule> _list = new BllHCRS_Cxlrule().getitem(" property_id=" + pid.ToString() + "  and languagetype=" + base.LanguageId.ToString() + " ");
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tcountry\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"95%\"><tr class=\"title1\" height=\"26\"><td style=\"color: white;width:60px\">"+EZCRS.HCMS.myajax.Site.StrNumb+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrCode+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrName+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrRemark+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrSystemGrade+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrUpdateTime+"</td><td style=\"color: white;width:60px;\">"+EZCRS.HCMS.myajax.Site.StrDetail+"</td></tr>");
            int row = 0;
            foreach (HCRS_CxlRule _cxl in _list)
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" ");
                rstr.Append(" >");
                rstr.Append("<td>" + row.ToString()+ "</td>");
                rstr.Append("<td>" + _cxl.Rule + "</td>");
                rstr.Append("<td>" + _cxl.Rulename + "</td>");
                rstr.Append("<td>" + _cxl.Description + "</td>");
                rstr.Append("<td>" + _cxl.Rulelevel.ToString() + "</td>");
                rstr.Append("<td>" + _cxl.updatetime.ToString() + "</td>");
                rstr.Append("<td><a href=\"cxlruleadd.aspx?id="+_cxl.id.ToString()+"\"><img src=\"../../image/modify.gif\" border=\"0\"/></a></td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            return rstr.ToString(); 
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getroomact()
        {
            int pid = BasPropertyId;
            List<HCRS_RoomCode> _list = new Bllh_roomcode().getitem(" pid=" + pid.ToString() + "  and languagetype=" + base.LanguageId.ToString() + " ");
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tcountry\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"95%\"><tr class=\"title1\" height=\"26\"><td style=\"color: white;width:60px\">"+EZCRS.HCMS.myajax.Site.StrNumb+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrRoomCode+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrRoomName+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrRemark+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrUpdateTime+"</td><td style=\"color: white;width:60px;\">"+EZCRS.HCMS.myajax.Site.StrDetail+"</td></tr>");
            int row = 0;
            foreach (HCRS_RoomCode _code in _list)
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" ");
                rstr.Append(" >");
                rstr.Append("<td>" + row.ToString() + "</td>");
                rstr.Append("<td>" + _code.roomcode + "</td>");
                rstr.Append("<td>" + _code.roomname + "</td>");
                rstr.Append("<td>" + _code.remark + "</td>");
                rstr.Append("<td>" + _code.updatetime.ToString() + "</td>");
                rstr.Append("<td><a href=\"roomactadd.aspx?id=" + _code.id.ToString() + "\"><img src=\"../../image/modify.gif\" border=\"0\"/></a></td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            return rstr.ToString();
        }

        [AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
        public string getreciveinfo()
        {
            int pid = BasPropertyId;
            List<HCRS_ReceiveInfo> _list = new Bllh_receiveinfo().getitem(" pid=" + pid.ToString() + "");
            StringBuilder rstr = new StringBuilder();
            rstr.Append("<table id=\"tcountry\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"95%\"><tr class=\"title1\" height=\"26\"><td style=\"color: white;width:60px\">"+EZCRS.HCMS.myajax.Site.StrNumb+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrReciveType+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrReciveWay+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrAddress+"</td><td style=\"color: white;\">"+EZCRS.HCMS.myajax.Site.StrRemark+"</td><td style=\"color: white;width:60px;\">"+EZCRS.HCMS.myajax.Site.StrDetail+"</td></tr>");
            int row = 0;
            foreach (HCRS_ReceiveInfo _code in _list)
            {
                rstr.Append("<tr");
                if (row % 2 == 0)
                {
                    rstr.Append(" class='line-odd'");
                }
                else
                {
                    rstr.Append(" class='line-even'");
                }
                rstr.Append(" onmouseover=\"currentcolor=this.style.backgroundColor;this.style.backgroundColor='#B9CEEA';\"");
                rstr.Append(" onmouseout=\"this.style.backgroundColor=currentcolor;\" ");
                rstr.Append(" >");
                rstr.Append("<td>" + row.ToString() + "</td>");
                rstr.Append("<td>" + _code.type + "</td>");
                rstr.Append("<td>" + _code.way + "</td>");
                rstr.Append("<td>" + _code.address + "</td>");
                rstr.Append("<td>" + _code.remark + "</td>");
                rstr.Append("<td><a href=\"receiveinfoadd.aspx?id=" + _code.id.ToString() + "\"><img src=\"../../image/modify.gif\" border=\"0\"/></a></td>");
                rstr.Append("</tr>");
                row++;
            }
            rstr.Append("</table>");
            return rstr.ToString();
        }
    }
}
